package com.entrogy.controller;

import com.entrogy.bean.*;
import com.entrogy.service.CourseSystemService;
import com.entrogy.service.ParentService;
import com.entrogy.service.StudentService;
import com.entrogy.service.UserService;
import com.entrogy.utils.constants.ErrorEnum;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;


/**
 * @ClassName CourseSystemController
 * @Description
 * @Author luoxingjiang
 * @Date 2019-11-19 下午 6:28
 * @Version 1.0
 **/
@RestController
@RequestMapping(value = "/course-system")
@Api(description = "选课系统接口")
public class CourseSystemController {

    private static final Logger logger = LoggerFactory.getLogger(CourseSystemController.class);

    @Autowired
    private CourseSystemService courseSystemService;

    @Autowired
    private UserService userService;

    @Autowired
    private ParentService parentService;

    @Autowired
    private StudentService studentService;

    @ApiOperation(value = "查询课程")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "courseName", value = "课程名字", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "currentPage", value = "当前页", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "isFinish", value = "是否结束，false没有结束，true已结束", dataType = "Boolean", paramType = "query"),
            @ApiImplicitParam(name = "teacherName", value = "教师姓名", dataType = "String", paramType = "query"),
    })
    @GetMapping(value = "/course-list")
    public Msg listCourse(String uid, String courseName, Integer currentPage, Integer pageSize, Boolean isFinish, String teacherName) {
        Integer schoolCode = userService.getSchoolCodeByUserId(uid);
        if (schoolCode == null){
            schoolCode = parentService.getSchoolCodeByParentId(uid);
        }
        PageHelper.startPage(currentPage, pageSize);
        List<CourseSystemCourseEntity> courseList = courseSystemService.listCourse(null, courseName, schoolCode, isFinish, teacherName, 1);
        PageInfo<CourseSystemCourseEntity> pageInfo = new PageInfo<>(courseList);
        long totalCount = pageInfo.getTotal();
        for (CourseSystemCourseEntity course : courseList) {
            course.setCourseArrangeList(courseSystemService.listCourseTeacherArrange(course.getId()));
            course.setIsFinish(course.getDeadline().before(new Date()));
        }
        return Msg.success().add("courseList", courseList).add("totalCount", totalCount);
    }

    @ApiOperation(value = "查询课程详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "courseId", value = "课程id", dataType = "Integer", paramType = "query"),
    })
    @GetMapping(value = "/course-detail")
    public Msg listCourse(String uid, Integer courseId) {
        Integer schoolCode = userService.getSchoolCodeByUserId(uid);
        if (schoolCode == null){
            schoolCode = parentService.getSchoolCodeByParentId(uid);
        }
        List<CourseSystemCourseEntity> courseList = courseSystemService.listCourse(courseId, null, schoolCode, null, null, null);
        if (courseList.size() != 1){
            return Msg.fail(ErrorEnum.E_90003, ErrorEnum.E_90003.getErrorMsg());
        }
        // 查询这些课程的开课时间详情
        CourseSystemCourseEntity course = courseList.get(0);
        course.setCourseTimeList(courseSystemService.listCourseTime(courseId))
                .setCourseArrangeList(courseSystemService.listCourseTeacherArrange(courseId))
                .setCourseLimitList(courseSystemService.listCourseLimit(courseId, schoolCode))
                .setIsFinish(course.getDeadline().before(new Date()));
        // 是否可以编辑
        boolean canUpdate = false;
        if (course.getCreateUserId().equals(uid) && !course.getIsFinish()){
            canUpdate = true;
        }
        return Msg.success().add("course", course).add("canUpdate", canUpdate);
    }

    @ApiOperation(value = "新增课程")
    @PostMapping(value = "/course-add")
    public Msg addCourse(@RequestBody CourseSystemCourseEntity course) {
        course.setSchoolCode(userService.getSchoolCodeByUserId(course.getCreateUserId()));
        int result = courseSystemService.insertCourse(course);
        if (result == 1){
            return Msg.fail(ErrorEnum.E_101, "对不起，新增课程失败，设置的总课时数和安排的课时数不相等！");
        }else if (result == 2){
            return Msg.fail(ErrorEnum.E_101, "对不起，新增课程失败，班级限报人数不能大于科目限报人数！");
        }else if (result == 3){
            return Msg.fail(ErrorEnum.E_101, "对不起，新增课程失败，您设置了班级限报的同时必须设置授课对象！");
        }
        return Msg.success();
    }




    @ApiOperation(value = "删除课程")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "courseId", value = "课程id", dataType = "Integer", paramType = "query"),
    })
    @DeleteMapping(value = "/course-delete")
    public Msg deleteCourse(String uid, Integer courseId) {
        logger.info("用户=>" + uid + "正在删除课程=>" + courseId);
        // 判断是否处于启用状态
        CourseSystemCourseEntity course = isEnable(uid, courseId);
        if (course == null){
            return Msg.fail(ErrorEnum.E_101, "对不起，您不能删除已启用的课程！");
        }
        boolean deleteResult = courseSystemService.deleteCourse(courseId);
        return Msg.success();
    }

    @ApiOperation(value = "编辑课程")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "courseId", value = "课程id", dataType = "Integer", paramType = "query"),
    })
    @PutMapping(value = "/course-update")
    public Msg updateCourse(@RequestBody CourseSystemCourseEntity course) {
        logger.info("用户=>" + course.getOperateUserId() + "正在编辑课程=>" + course.toString());
        Integer updateResult = courseSystemService.updateCourse(course);
        if (updateResult == 0){
            return Msg.success();
        }else if (updateResult == 1){
            return Msg.fail(ErrorEnum.E_101, "对不起，修改课程失败，设置的总课时数和安排的课时数不相等！");
        }else if (updateResult == 2){
            return Msg.fail(ErrorEnum.E_90003, ErrorEnum.E_90003.getErrorMsg());
        }else if (updateResult == 3){
            return Msg.fail(ErrorEnum.E_101, "对不起，修改课程失败，当前该课程已报名人数已经大于您设置的课程限报人数！");
        }else if(updateResult == 4){
            return Msg.fail(ErrorEnum.E_101, "对不起，修改课程失败，每班限报人数不能超过课程限报人数！");
        }else if (updateResult == 5){
            return Msg.fail(ErrorEnum.E_101, "对不起，修改课程失败，您设置了班级限报的同时必须设置授课对象！");
        }
        return Msg.fail(ErrorEnum.E_101, ErrorEnum.E_101.getErrorMsg());
    }

    @ApiOperation(value = "启用课程")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "courseId", value = "课程id", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "enableStatus", value = "启用标志", dataType = "Integer", paramType = "query"),
    })
    @PutMapping(value = "/course-enable")
    public Msg enableCourse(String uid, Integer courseId, Integer enableStatus) {
        logger.info("用户=>" + uid + "正在启用课程=>" + courseId);
        boolean enableResult = courseSystemService.enableCourse(courseId, enableStatus);
        return Msg.success();
    }

    @ApiOperation(value = "教师查询自己的任课课程")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "courseName", value = "课程名字", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "currentPage", value = "当前页", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "isFinish", value = "是否结束，false没有结束，true已结束", dataType = "Boolean", paramType = "query"),
    })
    @GetMapping(value = "/list-teacher-course")
    public Msg listTeacherCourse(String uid, String courseName, Integer currentPage, Integer pageSize, Boolean isFinish) {
        PageHelper.startPage(currentPage, pageSize);
        List<CourseSystemCourseEntity> courseList = courseSystemService.listTeacherCourse(uid, courseName, isFinish);
        for (CourseSystemCourseEntity course : courseList) {
            course.setIsFinish(course.getDeadline().before(new Date()));
        }
        PageInfo<CourseSystemCourseEntity> pageInfo = new PageInfo<>(courseList);
        long totalCount = pageInfo.getTotal();
        return Msg.success().add("courseList", courseList).add("totalCount", totalCount);
    }

    @ApiOperation(value = "教师查询自己创建的课程")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "courseName", value = "课程名字", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "currentPage", value = "当前页", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "isFinish", value = "是否结束，false没有结束，true已结束", dataType = "Boolean", paramType = "query"),
            @ApiImplicitParam(name = "enableStatus", value = "是否启用", dataType = "Integer", paramType = "query"),
    })
    @GetMapping(value = "/list-teacher-create-course")
    public Msg listTeacherCreateCourse(String uid, String courseName, Integer currentPage, Integer pageSize, Boolean isFinish, Integer enableStatus) {
        PageHelper.startPage(currentPage, pageSize);
        List<CourseSystemCourseEntity> courseList = courseSystemService.listTeacherCreateCourse(uid, courseName, isFinish, enableStatus);
        for (CourseSystemCourseEntity course : courseList) {
            course.setIsFinish(course.getDeadline().before(new Date()));
        }
        PageInfo<CourseSystemCourseEntity> pageInfo = new PageInfo<>(courseList);
        long totalCount = pageInfo.getTotal();
        return Msg.success().add("courseList", courseList).add("totalCount", totalCount);
    }

    @ApiOperation(value = "查询已选该课程的学生")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "courseId", value = "课程id", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "isGroupByClass", value = "是否按班级分类，1就是按班级", dataType = "Integer", paramType = "query", required = true),
    })
    @GetMapping(value = "/list-course-student")
    public Msg listCourseStudent(String uid, Integer courseId, Integer isGroupByClass) {
        if (isGroupByClass != null && isGroupByClass == 1){
            List<ClassStudentEntity> studentList = courseSystemService.listCourseStudent(courseId, null);
            int totalCount = courseSystemService.countChooseStudent(courseId, null);
            return Msg.success().add("studentList", studentList).add("totalCount", totalCount);
        }
        List<StudentBasicInfoEntity> studentList = courseSystemService.listCourseStudentNotGroup(courseId);
        int totalCount = courseSystemService.countChooseStudent(courseId, null);
        return Msg.success().add("studentList", studentList).add("totalCount", totalCount);
    }

    @ApiOperation(value = "家长为孩子选课")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "courseId", value = "课程id", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "studentId", value = "学生", dataType = "Integer", paramType = "query", required = true),
    })
    @PostMapping(value = "/course-choose")
    public Msg chooseCourse(String uid, Integer courseId, Integer studentId) {
        List<StudentBasicInfoEntity> studentList = courseSystemService.listCourseStudentNotGroup(courseId);
        for (StudentBasicInfoEntity student : studentList) {
            if (student.getId().equals(studentId)){
                return Msg.fail(ErrorEnum.E_101, "对不起，选课失败，您已经选择该课程，不能重复选择！");
            }
        }
        Integer schoolCode = parentService.getSchoolCodeByParentId(uid);
        List<CourseSystemCourseEntity> courseList = courseSystemService.listCourse(courseId, null, schoolCode, null, null, 1);
        if (courseList.size() != 1){
            return Msg.fail(ErrorEnum.E_90003, ErrorEnum.E_90003.getErrorMsg());
        }
        // 查询这些课程的开课时间详情
        CourseSystemCourseEntity course = courseList.get(0);
        List<CourseSystemCourseLimitEntity> courseGradeLimitList = courseSystemService.listCourseLimit(courseId, schoolCode);
        Integer courseLimitCount = course.getCourseLimitCount();
        // 判断是否已完成
        if (course.getDeadline().before(new Date())){
            return Msg.fail(ErrorEnum.E_101, "对不起，该门课程选课已结束！");
        }
        // 判断已选课学生数量是否大于限报人数
        int totalCount = courseSystemService.countChooseStudent(courseId, null);
        if (courseLimitCount != null && totalCount >= courseLimitCount){
            return Msg.fail(ErrorEnum.E_101, "对不起，该门课程已无选课名额");
        }
        // 判断该生所在年级是否能够报名
        StudentEntity student = studentService.getStudentById(studentId);
        if (courseGradeLimitList.size() > 0){
            if (student == null){
                return Msg.fail(ErrorEnum.E_101, "对不起，学生ID有误！");
            }
            Integer gradeId = student.getGradeId();
            boolean canChoose = false;
            for (CourseSystemCourseLimitEntity courseGradeLimit : courseGradeLimitList) {
                if (gradeId.equals(courseGradeLimit.getLimitGradeId())){
                    canChoose = true;
                }
            }
            if (!canChoose){
                return Msg.fail(ErrorEnum.E_101, "对不起，该生所在年级不能选择该课程！");
            }
        }
        // 判断该生所在班级是否已经选满
        Integer classLimitCount = course.getClassLimitCount();
        if (classLimitCount != null && classLimitCount != 0){
            int classChooseCourse = courseSystemService.countChooseStudent(courseId, student.getCourseId());
            if (classChooseCourse >= classLimitCount){
                return Msg.fail(ErrorEnum.E_101, "对不起，该生所在班级已无选课名额！");
            }
        }
        boolean chooseCourseResult = courseSystemService.chooseCourse(uid, courseId, studentId);
        return Msg.success();
    }

    @ApiOperation(value = "查看孩子的选课列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "studentId", value = "学生", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "currentPage", value = "当前页", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "courseName", value = "课程名称", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "teacherName", value = "老师姓名", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "isFinish", value = "是否结束，false没有结束，true已结束", dataType = "Boolean", paramType = "query"),
    })
    @GetMapping(value = "/list-student-course")
    public Msg chooseCourse(String uid, Integer studentId, Integer currentPage, Integer pageSize, String courseName, String teacherName, Boolean isFinish) {
        if (currentPage == null || pageSize == null){
            currentPage = 0;
            pageSize = 0;
        }
        PageHelper.startPage(currentPage, pageSize);
        List<CourseSystemParentCourseEntity> courseList = courseSystemService.listParentOrStudentCourse(uid, studentId, courseName, teacherName, isFinish);
        PageInfo<CourseSystemParentCourseEntity> pageInfo = new PageInfo<>(courseList);
        long totalCount = pageInfo.getTotal();
        for (CourseSystemParentCourseEntity course : courseList) {
            course.setCourseArrangeList(courseSystemService.listCourseTeacherArrange(course.getId()))
                  .setCourseLimitList(courseSystemService.listCourseLimit(course.getId(), null))
                  .setCourseTimeList(courseSystemService.listCourseTime(course.getId()));
            course.setIsFinish(course.getDeadline().before(new Date()));
        }
        return Msg.success().add("courseList", courseList).add("totalCount", totalCount);
    }

    @ApiOperation(value = "查询已选该课程的学生---用于评分")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "courseId", value = "课程id", dataType = "Integer", paramType = "query", required = true),
    })
    @GetMapping(value = "/list-course-student-score")
    public Msg listCourseStudentScore(String uid, Integer courseId) {
        List<StudentBasicInfoEntity> studentList = courseSystemService.listCourseStudentNotGroup(courseId);
        for (StudentBasicInfoEntity student : studentList) {
            // 查询该生的选课信息
            CourseSystemStudentScoreEntity studentScoreInfo = courseSystemService.getStudentChooseInfo(student.getId(), courseId);
            student.setCourseSystemStudentScore(studentScoreInfo);
        }
        int totalCount = courseSystemService.countChooseStudent(courseId, null);
        return Msg.success().add("studentList", studentList).add("totalCount", totalCount);
    }

    @ApiOperation(value = "教师评分选课学生")
    @PutMapping(value = "/teacher-give-score")
    public Msg teacherGiveScore(@RequestBody List<CourseSystemStudentScoreEntity> studentScoreList) {
        if (studentScoreList == null || studentScoreList.size() == 0){
            return Msg.fail(ErrorEnum.E_90003, ErrorEnum.E_90003.getErrorMsg());
        }
        logger.info("正在对选课评分=>" + studentScoreList);
        boolean enableResult = courseSystemService.teacherGiveScore(studentScoreList);
        return Msg.success();
    }

    @ApiOperation(value = "教师删除选课学生")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "courseChooseId", value = "选课记录id", dataType = "Integer", paramType = "query"),
    })
    @DeleteMapping(value = "/delete-student")
    public Msg teacherGiveScore(String uid , Integer courseChooseId) {
        // 删除选课学生前需要，判断该选课id是否已经处于课程报名结束时间后，如果是的话，那么不能移除选课学生
        CourseSystemChooseEvaluateEntity courseChooseInfo = courseSystemService.getCourseChooseInfo(courseChooseId);
        Integer courseId = courseChooseInfo.getCourseId();
        List<CourseSystemCourseEntity> courseList = courseSystemService.listCourse(courseId, null, null, true, null, 1);
        if (courseList.size() > 0){
            return Msg.fail(ErrorEnum.E_101, "对不起，删除失败，该课程已经开始");
        }
        logger.info("用户=>" + uid + "正在进行移除选课学生操作，选课id=>" + courseChooseId);
        boolean deleteResult = courseSystemService.deleteStudent(courseChooseId);
        return Msg.success();
    }

    @ApiOperation(value = "教师查询选课学生点名情况用于点名")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "courseId", value = "课程id", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "weekOrder", value = "第几周", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "dayOfWeek", value = "星期几", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "courseOrder", value = "节数", dataType = "Integer", paramType = "query", required = true),
    })
    @GetMapping(value = "/list-student-check")
    public Msg ListStudentForCheck(String uid , Integer courseId, Integer weekOrder, Integer dayOfWeek, Integer courseOrder) {
        List<StudentBasicInfoEntity> studentList = courseSystemService.listStudentCheckRecord(courseId, weekOrder, dayOfWeek, courseOrder, null, null);
        return Msg.success().add("studentList", studentList);
    }

    @ApiOperation(value = "教师进行学生点名，可能新增点名记录，可能修改点名记录")
    @PostMapping(value = "/check-student")
    public Msg checkStudent(@RequestBody List<CourseSystemAttendanceEntity> courseAttendanceList) {
        boolean checkStudentResult = courseSystemService.checkStudent(courseAttendanceList);
        return Msg.success();
    }

//    @ApiOperation(value = "教师修改以前的点名记录，修改点名记录，集成到教师点名接口")
//    @PostMapping(value = "/update-check-student")
//    public Msg updateCheckStudentStatus(@RequestBody CourseSystemAttendanceEntity courseAttendance) {
//        boolean updateCheckStudentStatusResult = courseSystemService.updateCheckStudentStatus(courseAttendance);
//        return Msg.success();
//    }

    @ApiOperation(value = "家长为孩子退课")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "courseChooseId", value = "选课记录id", dataType = "Integer", paramType = "query"),
    })
    @PostMapping(value = "/drop-course")
    public Msg dropCourse(String uid , Integer courseChooseId) {
        boolean dropCourseResult = courseSystemService.dropCourse(courseChooseId);
        return Msg.success();
    }

    @ApiOperation(value = "家长评价课程")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "courseChooseId", value = "选课记录id", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "evaluateTeacher", value = "评论内容", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "parentScore", value = "家长评分", dataType = "Integer", paramType = "query"),
    })
    @PostMapping(value = "/evaluate-teacher")
    public Msg evaluateTeacher(String uid , Integer courseChooseId, String evaluateTeacher, Integer parentScore) {
        boolean dropCourseResult = courseSystemService.evaluateTeacher(courseChooseId, evaluateTeacher, parentScore);
        return Msg.success();
    }

    @ApiOperation(value = "家长、教师查询互评接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "courseChooseId", value = "选课记录id", dataType = "Integer", paramType = "query", required = true),
    })
    @GetMapping(value = "/course-evaluate")
    public Msg courseEvaluate(String uid , Integer courseChooseId) {
        CourseSystemChooseEvaluateEntity courseChooseInfo = courseSystemService.getCourseChooseInfo(courseChooseId);
        courseChooseInfo.setCourseArrangeList(courseSystemService.listCourseTeacherArrange(courseChooseInfo.getCourseId()));
        return Msg.success().add("courseChooseInfo", courseChooseInfo);
    }

    @ApiOperation(value = "家长查询点名记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "用户id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "courseId", value = "课程id", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "weekOrder", value = "第几周", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "dayOfWeek", value = "星期几", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "courseOrder", value = "节数", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "studentId", value = "学生名", dataType = "String", paramType = "query", required = true),
    })
    @GetMapping(value = "/list-student-check-record")
    public Msg courseEvaluate(String uid , Integer courseId, Integer weekOrder, Integer dayOfWeek, Integer courseOrder, Integer studentId) {
        List<StudentBasicInfoEntity> studentCheckRecordList = courseSystemService.listStudentCheckRecord(courseId, weekOrder, dayOfWeek, courseOrder, null, studentId);
        return Msg.success().add("studentCheckRecordList", studentCheckRecordList);
    }


    private CourseSystemCourseEntity isEnable(String uid, Integer courseId){
        // 判断是否处于启用状态
        Integer schoolCode = userService.getSchoolCodeByUserId(uid);
        List<CourseSystemCourseEntity> courseList = courseSystemService.listCourse(courseId, null, schoolCode, null, null, 0);
        if (courseList == null || courseList.size() != 1){
            return null;
        }
        return courseList.get(0);
    }


}
